package dryven.util;

import java.util.Enumeration;
import java.util.Iterator;

public class EnumerationIterable<T> implements Iterable<T> {

	public EnumerationIterable(Enumeration<T> enumeration) {
		super();
		this.enumeration = enumeration;
	}

	private Enumeration<T> enumeration;
	
	@Override
	public Iterator<T> iterator() {
		return new EnumerationIterator<T>();
	}
	
	class EnumerationIterator<E> implements Iterator<E> {

		@Override
		public boolean hasNext() {
			return enumeration.hasMoreElements();
		}

		@Override
		public E next() {
			return (E) enumeration.nextElement();
		}

		@Override
		public void remove() {
			throw new UnsupportedOperationException();
		}
		
	}
}

